package RLK_NIO;

public class Example_02 {
    public void channelData(final FileInputStream stream, final byte[] data) {
        DatagramChannel ch = null;
        try {
            ch = DatagramChannel.open(); // Resource allocated
            try {
                ch.configureBlocking(true);
                ByteBuffer packet = ByteBuffer.wrap(data);
                ch.send(packet, dest);
            } finally {
                ch.close(); // Resource released
            }
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
    }
}
